package com.sisgh.jefdv1.core.java.keyword.imports.impl;

import com.sisgh.jefdv1.core.java.keyword.imports.Import;
import com.sisgh.jefdv1.core.java.keyword.pack.Package;
import lombok.Getter;

@Getter
public enum Annotation implements Import {
    DATA(Package.of("lombok"), "Data"),
    EQUALS_AND_HASHCODE(Package.of("lombok"), "EqualsAndHashCode", new String[]{"callSuper = true"}),
    ;

    private final Package packagePath;
    private String[] values;
    private final String name;

    Annotation(final Package packagePath, final String name) {
        this.packagePath = packagePath;
        this.name = name;
    }

    Annotation(Package packagePath, final String name, String[] values) {
        this.packagePath = packagePath;
        this.name = name;
        this.values = values;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append('@').append(name);

        if (values == null || values.length == 0) {
            return sb.toString();
        }

        sb.append("(");
        for (String value : values) {
            sb.append(value);
        }
        sb.append(")");

        return sb.toString();
    }

    @Override
    public String getImport() {
        return "import " + packagePath.getPath() + "." + name;
    }
}
